package poketrade;

import java.io.IOException;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import poketrade.entities.User;
import poketrade.managers.DealManager;
/**
 * Servlet implementation class MyDealServlet
 */
@WebServlet("/MyDealServlet")
public class MyDealServlet extends BaseHttpServlet {
	private static final long serialVersionUID = 1L;
       
	@EJB
	private DealManager mgr;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		User currentuser = (User) session.getAttribute("user");
		User u = mgr.fetchPendingOffersForUser(currentuser);
		request.setAttribute("pendingOffers", u.getOffers());
		forward(request, response, "mesAnnoncesxml.jsp");
	}
		
}
